﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NavFob
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.txtHexaString.Text))
                {
                    string text = NAV2013BLOBReader.ReadFromDB(txtServer.Text, txtDatabase.Text, txtUserName.Text, txtPass.Text, txtObjctID.Text, comboBox1.SelectedIndex);
                    txtContent.Text = text;
                }
                else
                {
                    if (this.txtHexaString.Text.StartsWith("0x"))
                    {
                        this.txtHexaString.Text = this.txtHexaString.Text.Remove(0, 2);
                    }
                    string text = NAV2013BLOBReader.ReadFromHexaString(this.txtHexaString.Text);
                   
                    txtContent.Text = text;
                }


            }
            catch(Exception ex)
            {
                while (ex.InnerException != null)
                    ex = ex.InnerException;
                MessageBox.Show(ex.Message);
            }
        }

       
    }
}
